package com.lucky.auth_boot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lucky.auth_boot.mapper.LoginLogMapper;
import com.lucky.auth_boot.pojo.dto.LoginLogDTO;
import com.lucky.auth_boot.pojo.dto.UserDTO;
import com.lucky.auth_boot.pojo.po.LoginLogPO;
import com.lucky.auth_boot.pojo.vo.LoginLogVO;
import com.lucky.auth_boot.service.LoginLogService;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Pageable;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoginLogServiceImpl implements LoginLogService {

    @Resource
    private LoginLogMapper loginLogMapper;

    @Override
    public Page<LoginLogVO> queryLoginLogList(Pageable pageable) {
        Page<LoginLogPO> page = new Page<>(pageable.getPageNumber(),pageable.getPageSize());
        return loginLogMapper.queryLoginLogList(page);
    }

    @Override
    public Integer postLoginLog(LoginLogDTO loginLogDTO) {
        LoginLogPO loginLogPO = new LoginLogPO();
        BeanUtils.copyProperties(loginLogDTO,loginLogPO);
        return loginLogMapper.insert(loginLogPO);
    }
}
